#ifndef ADAPTOR_SERVER_H_
#define ADAPTOR_SERVER_H_

#include "adaptorsocket.h"
#include "afxtempl.h"
#include "orderlink.h"
#include "marketdatalink.h"
#include "AdaptorDlgBase.h"
#include "comminstrument.h"
#include "config.h"

#include <list>

using namespace std;

class AdaptorServer : public CSocket
{
public:
	AdaptorServer(OrderLink *ol, MarketDataLink *ml, AdaptorDlgBase *dialog);
	~AdaptorServer();
	void startServer();
	virtual void OnAccept(int nErrorCode);
	void clientClosed(AdaptorSocket *socket);
	void clientLogin(AdaptorSocket *socket, const ZAdaptorLoginMessage *msg);
	void reqMarketData(AdaptorSocket *socket, const ZAdaptorMarketDataSubMessage *msg);

private:
	void loadAllInstruments();
private:
	list<AdaptorSocket *>		mSocketList;
	OrderLink					*mOrderLink;
	MarketDataLink				*mMarketDataLink;
	AdaptorDlgBase				*mDialog;
	Config						*mConfig;
	
	CommInstrumentList			*mInstrumetList;
};

#endif //ADAPTOR_SERVER_H_